package top.lbqaq.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

@WebServlet(name = "Servlet5", value = "/Servlet5")
public class Servlet5 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String a = request.getParameter("a");
        String[] bs = request.getParameterValues("b");
        List<String> bl = null;
        if (bs != null) {
            // 转换成List，方便使用contains()方法
            bl = Arrays.asList(bs);
        }
        String c = request.getParameter("c");
        String d = request.getParameter("d");
        // DO SOMETHING HERE
        request.setAttribute("A", a);
        request.setAttribute("BL", bl);
        request.setAttribute("C", c);
        request.setAttribute("D", d);
        request.getRequestDispatcher("/5.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
